﻿Public Class Form1

    Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
        If ComboBox1.SelectedItem = "DES" Then
            Passform.Label1.Text = "Tips for a secure password"
            Passform.lbl_title.Text = "DES"
            Passform.tb_pwd2.Enabled = False
            Passform.tb_pwd3.Enabled = False
            Passform.lbl_pwd2.Enabled = False
            Passform.lbl_pwd3.Enabled = False
            Exit Sub
        ElseIf ComboBox1.SelectedItem = "Fractal encryption" Then
            Passform.Label1.Text = "Numbers only!"
            Passform.txtnumber = True
            Passform.lbl_title.Text = "Fractal encryption"
            Passform.tb_pwd2.Enabled = False
            Passform.tb_pwd3.Enabled = False
            Passform.lbl_pwd2.Enabled = False
            Passform.lbl_pwd3.Enabled = False
        ElseIf ComboBox1.SelectedItem = "AES (Rijndael)" Then
            Passform.lbl_title.Text = "AES (Rijndael)"
            Passform.lbl_pwd2.Enabled = True
            Passform.tb_pwd2.Enabled = True
            Passform.lbl_pwd3.Enabled = True
            Passform.tb_pwd3.Enabled = True
            Exit Sub
        End If
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        My.Settings.Encrypt = True
        If ComboBox1.SelectedItem = "Rijndael Simple" Then
            Timer1.Start()
            Exit Sub
        ElseIf ComboBox1.SelectedItem = "Basic Encryption" Then
            Timer1.Start()
            Exit Sub
        End If
        If ComboBox1.SelectedItem = "DES" Then
            Passform.Show()
            Passform.tmr_appear.Start()
            Timer1.Enabled = False
            Exit Sub
        ElseIf ComboBox1.SelectedItem = "Fractal encryption" Then
            Passform.Show()
            Passform.tmr_appear.Start()
            Timer1.Enabled = False
            Exit Sub
        ElseIf ComboBox1.SelectedItem = "AES (Rijndael)" Then
            Passform.Show()
            Passform.tmr_appear.Start()
            Timer1.Enabled = False
            Exit Sub
        End If
        ComboBox1.Focus()
    End Sub
    Dim black As Boolean = True
    Dim dimgray As Boolean = False
    Dim grey As Boolean = False
    Dim darkgray As Boolean = False
    Dim silver As Boolean = False
    Dim lightgray As Boolean = False
    Dim grainsboro As Boolean = False
    Dim white As Boolean = False
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Timer1.Interval = 25

        If (black = True) Then

            RichTextBox1.ForeColor = Color.DimGray
            dimgray = True
            black = False
            Return
        End If
        If (dimgray = True) Then

            RichTextBox1.ForeColor = Color.Gray
            grey = True
            dimgray = False
            Return
        End If
        If (grey = True) Then

            RichTextBox1.ForeColor = Color.DarkGray
            darkgray = True
            grey = False
            Return
        End If
        If (darkgray = True) Then

            RichTextBox1.ForeColor = Color.Silver
            silver = True
            darkgray = False
            Return
        End If
        If (silver = True) Then

            RichTextBox1.ForeColor = Color.LightGray
            lightgray = True
            silver = False
            Return
        End If
        If (lightgray = True) Then

            RichTextBox1.ForeColor = Color.Gainsboro
            grainsboro = True
            lightgray = False
            Return
        End If
        If (grainsboro = True) Then

            RichTextBox1.ForeColor = Color.WhiteSmoke
            whitesmoke = True
            grainsboro = False
            Return
        End If
        If (whitesmoke = True) Then
            black = False
            dimgray = False
            grey = False
            darkgray = False
            silver = False
            lightgray = False
            grainsboro = False
            If My.Settings.Encrypt = True Then
                If ComboBox1.SelectedItem = "Rijndael Simple" Then
                    RichTextBox1.Text = Rijndael.Encrypt(RichTextBox1.Text)
                ElseIf ComboBox1.SelectedItem = "Basic Encryption" Then
                    RichTextBox1.Text = Basic_encryption.SimpleCrypt(RichTextBox1.Text)
                Else
                    RichTextBox1.Text = My.Settings.text
                End If
            Else
                If ComboBox1.SelectedItem = "Rijndael Simple" Then
                    RichTextBox1.Text = Rijndael.Decrypt(RichTextBox1.Text)
                ElseIf ComboBox1.SelectedItem = "Basic Encryption" Then
                    RichTextBox1.Text = Basic_encryption.SimpleCrypt(RichTextBox1.Text)
                Else
                    RichTextBox1.Text = My.Settings.text
                End If

            End If
            Timer2.Start()
            Timer1.Enabled = False
        End If
    End Sub

    Private Sub tmr_appear_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_appear.Tick
        Dim opacFact As Double = 0.05
        Do While tmr_fade.Enabled = True
            Exit Sub
        Loop
        Me.Opacity = Me.Opacity + opacFact
        If (Me.Opacity = 1) Then
            tmr_appear.Stop()
        End If
    End Sub

    Private Sub lbl_close_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lbl_close.MouseDown
        lbl_close.ForeColor = Color.DarkGray
    End Sub

    Private Sub lbl_close_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lbl_close.MouseUp
        lbl_close.ForeColor = Color.WhiteSmoke
        tmr_fade.Enabled = True
        tmr_fade.Start()
    End Sub

    Private Sub tmr_fade_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_fade.Tick
        Dim opacFact As Double = 0.05
        Me.Opacity = Me.Opacity - opacFact

        If (Me.Opacity = 0) Then
            Me.Close()
            tmr_fade.Stop()
        End If
    End Sub


    Private Sub lbl_close_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl_close.MouseHover
        lbl_close.ForeColor = Color.Gainsboro
    End Sub

    Private Sub lbl_close_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl_close.MouseLeave
        lbl_close.ForeColor = Color.WhiteSmoke
    End Sub



    Dim newPoint As New System.Drawing.Point()
    Dim a As Integer
    Dim b As Integer



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Text = "Choose an algorithm"
        tmr_appear.Start()
    End Sub

    Private Sub RichTextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.Click
        If Timer1.Enabled = True Then
            RichTextBox2.Focus()
        End If
    End Sub


    Private Sub ComboBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ComboBox1.MouseMove
        If ComboBox1.SelectedItem = "" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Low security (no password required):" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Medium Security:" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "High security:" Then
            ComboBox1.Text = "Choose an algorithm"
        End If
    End Sub

    Private Sub ComboBox1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.MouseLeave

        If ComboBox1.SelectedItem = "" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Low security (no password required):" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Medium Security:" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "High security:" Then
            ComboBox1.Text = "Choose an algorithm"
        End If
    End Sub
    Private Sub RichTextBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseMove
        If ComboBox1.SelectedItem = "" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Low security (no password required):" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Medium Security:" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "High security:" Then
            ComboBox1.Text = "Choose an algorithm"
        End If
    End Sub

    Private Sub Panel3_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown

        a = Control.MousePosition.X - Me.Location.X
        b = Control.MousePosition.Y - Me.Location.Y

    End Sub

    Private Sub Panel3_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

        If e.Button = MouseButtons.Left Then
            newPoint = Control.MousePosition
            newPoint.X = newPoint.X - (a)
            newPoint.Y = newPoint.Y - (b)
            Me.Location = newPoint
        End If
        If ComboBox1.SelectedItem = "" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Low security (no password required):" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "Medium Security:" Then
            ComboBox1.Text = "Choose an algorithm"
        ElseIf ComboBox1.SelectedItem = "High security:" Then
            ComboBox1.Text = "Choose an algorithm"
        End If

    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        My.Settings.Encrypt = False
        If ComboBox1.SelectedItem = "Rijndael Simple" Then
            Timer1.Start()
            Exit Sub
        ElseIf ComboBox1.SelectedItem = "Basic Encryption" Then
            Timer1.Start()
            Exit Sub
        End If
        If ComboBox1.SelectedItem = "DES" Then
            Passform.Show()
            Passform.tmr_appear.Start()
            Timer1.Enabled = False
            Exit Sub
        ElseIf ComboBox1.SelectedItem = "Fractal encryption" Then
            Passform.Show()
            Passform.tmr_appear.Start()
            Timer1.Enabled = False
            Exit Sub
        ElseIf ComboBox1.SelectedItem = "AES (Rijndael)" Then
            Passform.lbl_pwd2.Enabled = True
            Passform.tb_pwd2.Enabled = True
            Passform.Show()
            Passform.tmr_appear.Start()
            Timer1.Enabled = False
            Exit Sub
        End If
        ComboBox1.Focus()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        About_box.Show()
    End Sub

  
  
    Dim whitesmoke As Boolean = False
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Timer2.Interval = 25
        If Timer1.Enabled = True Then
            Exit Sub
        End If

        If (whitesmoke = True) Then

            RichTextBox1.ForeColor = Color.Gainsboro
            grainsboro = True
            whitesmoke = False
            Return
        End If
        If (grainsboro = True) Then

            RichTextBox1.ForeColor = Color.LightGray
            lightgray = True
            grainsboro = False
            Return
        End If
        If (lightgray = True) Then

            RichTextBox1.ForeColor = Color.Silver
            silver = True
            lightgray = False
            Return
        End If
        If (silver = True) Then

            RichTextBox1.ForeColor = Color.DarkGray
            darkgray = True
            silver = False
            Return
        End If
        If (darkgray = True) Then
            RichTextBox1.ForeColor = Color.DimGray
            dimgray = True
            darkgray = False
            Return
        End If
        If (dimgray = True) Then

            RichTextBox1.ForeColor = Color.Black
            black = True
            dimgray = False
            Return
        End If
        If (black = True) Then


            white = False
            black = True
            dimgray = False
            grey = False
            darkgray = False
            silver = False
            lightgray = False
            grainsboro = False
            Timer2.Enabled = False

            Return
        End If
    End Sub
End Class
